//
//  ViewController.m
//  XWSegmentedControlTest
//
//  Created by wzl on 2017/3/15.
//  Copyright © 2017年 亮哥. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (strong, nonatomic) IBOutlet UITableView *myTableView;
@property (strong, nonatomic) NSArray *myDataSource;
@end

@implementation ViewController
#pragma mark - 父类方法
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.myTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"myCell"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 私有方法
-(NSArray *)myDataSource{
    if (!_myDataSource) {
        _myDataSource = @[@"手写代码调用",@"xib调用",@"样式设置"];
    }
    
    return _myDataSource;
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.myDataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:@"myCell" forIndexPath:indexPath];
    NSString *title = [self.myDataSource objectAtIndex:indexPath.row];
    cell.textLabel.text = title;
    return cell;
}

#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *indentifier = nil;
    switch (indexPath.row) {
        case 0:
            indentifier = @"testCodeVC";
            break;
        case 1:
            indentifier = @"testXibVC";
            break;
        case 2:
            indentifier = @"testSetStyleVC";
            break;
        default:
            break;
    }
    
    if (indentifier  != nil) {
        [self performSegueWithIdentifier:indentifier sender:tableView];
    }
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    
}

@end
